/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ps.yj.y1j0.rest;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;

import org.jboss.resteasy.annotations.cache.NoCache;
import ps.yj.y1j0.business.KVData.YJKVDataHandler;
import ps.yj.y1j0.business.YJDataHandler;
import ps.yj.y1j0.data.YJResult;

import java.sql.SQLException;
import java.util.List;

/**
 * @author yanjun
 */
@Path("/get")
@NoCache
public class YJRestGet {
    @GET
    @Path("/kv/{name}")
    @Produces(MediaType.APPLICATION_JSON)
    public YJResult queryKVData(@PathParam("name") String name) {
        YJResult resultData = new YJResult();
        YJDataHandler handler = new YJKVDataHandler(name, "rowid");
        String sql = "SELECT *,rowid FROM " + name;
        List resultList = handler.select(sql, null, null, null);
        resultData.setStatus(Boolean.TRUE);
        resultData.setData(resultList);
        return resultData;
    }
}
